package com.lindroy.androidplayer.extensions

import com.google.gson.Gson
import com.lindroy.androidplayer.constants.SP_KEY_LOGIN_INFO
import com.lindroy.androidplayer.logic.model.LoginResp
import com.lindroy.lib_utils.extensions.getSpStrSet
import com.lindroy.lib_utils.extensions.getSpString

/**
 * @author Lin
 * @date 2021/4/16
 * @function
 */
val globalLoginInfo: LoginResp
    get() {
        val result = getSpString(SP_KEY_LOGIN_INFO)
        return result.isEmpty().yes {
            LoginResp()
        }.no {
            Gson().fromJson(result, LoginResp::class.java)
        }
    }

val isLogin:Boolean
get() = globalLoginInfo.isLogin